﻿using System;
using System.Collections.Generic;
using System.Linq;
using CvModel;
using DAL;

namespace LAB3_Cv
{
    public partial class CvDetails : System.Web.UI.Page
    {
        private Applicant _currentApplicant;

        protected void Page_Load(object sender, EventArgs e)
        {
            _currentApplicant = Session["CurrentUser"] as Applicant;

            if (!IsPostBack)
            {
                LoadCvData();
            }
        }
        private void LoadCvData()
        {
            var cvList = new List<Cv>();

            var userCv = CvDB.GetCvInstanceWithApplicantId(_currentApplicant.ApplicantId);
            cvList.Add(userCv);

            ListViewInfo.DataSource = cvList;
            ListViewInfo.DataBind();

            var currentUserEducations = userCv.Educations.ToList();

            ListViewEducation.DataSource = currentUserEducations;
            ListViewEducation.DataBind();

            var currentUserExperiences = userCv.Experiences.ToList();

            ListViewExperiences.DataSource = currentUserExperiences;
            ListViewExperiences.DataBind();

            var currentUserMerit = userCv.Merits.ToList();

            ListViewMerits.DataSource = currentUserMerit;
            ListViewMerits.DataBind();
        }

        protected void ButtonEditCv_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/EditCvDetails.aspx");
        }
    }
}